-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Initial driver-kotlin-sync implementation #1090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f73dbb6 to
c7b32d2
Compare
Wraps the driver-sync to provide a kotlin sync API In general a faithful wrapping of the sync java driver. Uses reified overloads to provide synaptic sugar instead of passing resultClass. MongoIterable deviates from the sync API so to not implement Iterable in order to protect the user from leaving open cursors. In Kotlin there are two Iterable style implementations: Iterable and Sequence neither are auto closable. Sequence is more appropriate here as it lazily consumes the iterator, but it does not auto close. See: https://youtrack.jetbrains.com/issue/KT-34719 So MongoIterable provides a loan method that treats the cursor as a Sequence and automatically closes after use. JAVA-4869
driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/CrudTest.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoIterable.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoIterable.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoIterable.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/AggregateIterableTest.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/AggregateIterableTest.kt
Show resolved
Hide resolved
Also updates noticed when working with the coroutine api
jyemin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave it a good first look.
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/ClientSession.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoIterable.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoIterable.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoClient.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoChangeStreamCursor.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/integration/kotlin/com/mongodb/kotlin/client/UnifiedCrudTest.kt
Show resolved
Hide resolved
katcharov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked over the wrappers, looked good, and nice straightforward handling of the default parameters. A few minor comments related to the tests.
driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListDatabasesIterableTest.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/ListDatabasesIterableTest.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoChangeStreamCursorTest.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/test/kotlin/com/mongodb/kotlin/client/MongoClientTest.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoClient.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoClient.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoIterable.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCollection.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt
Show resolved
Hide resolved
katcharov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
For some reason I can not resolve my own comments, but the PR is ok for me |
…unctions that return the same result when the object state remains the same
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCursor.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoClient.kt
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/AggregateIterable.kt
Outdated
Show resolved
Hide resolved
driver-kotlin-sync/src/main/kotlin/com/mongodb/kotlin/client/MongoCursor.kt
Outdated
Show resolved
Hide resolved
jyemin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Will manually rebase and squash |
Wraps the driver-sync to provide a kotlin sync API
In general a faithful wrapping of the sync java driver. Uses reified overloads to provide syntactic sugar instead of passing resultClass.
MongoIterable deviates from the sync API so to not implement Iterable in order to protect the user from leaving open cursors. In Kotlin there are two Iterable style implementations: Iterable and Sequence neither are auto closable. Sequence is more appropriate here as it lazily consumes the iterator, but it does not auto close. See: https://youtrack.jetbrains.com/issue/KT-34719 So MongoIterable provides a loan method that treats the cursor as a Sequence and automatically closes after use.
JAVA-4869
Todo
maxTime(maxTime: Long, timeUnit: TimeUnit = TimeUnit.MILLISECONDS)MongoIterablethe correct name?com.mongodb.kotlin.client